import "@/utils/extends";
import { message as $message } from "ant-design-vue";
import appStore from "@/store/modules/app";
const destroy = (): void => {
    const app = appStore();
    if (!!app.loadingType) app.loadingType();
};
export default {
    /**
     * 消息提示
     * @param msg
     */
    toast: (msg: string): void => {
        destroy();
        $message.info(msg, 3);
    },
    /**
     * 错误消息
     * @param msg
     */
    error: (msg: string): void => {
        destroy();
        $message.error(msg, 3);
    },
    /**
     * 成功消息
     * @param msg
     */
    success: (msg: string): void => {
        destroy();
        $message.success(msg, 3);
    },
    warning: (msg: string): void => {
        destroy();
        $message.warning(msg, 3);
    },
    /**
     * 加载消息
     * @param msg
     */
    laoding: (msg: string): void => {
        const app = appStore();
        let loadingType = $message.loading(msg, 0);
        app.setloadingType(loadingType);
    },
    /**
     * 清除加载中的消息
     */
    destroy: (): void => {
        destroy();
    },
    /**
     * 网站目录
     * @param url
     * @returns 站点根目录+url
     */
    toUrl: (url: string): string => {
        return import.meta.env.VITE_BASE_URL + url;
    },
    toApiUrl: (url: string): string => {
        return import.meta.env.VITE_BASE_API_URL + url;
    },
};
